package 线程打断;

public class Test1 {

    public static void main(String[] args) throws InterruptedException {
        boolean isQuit = false;
        Thread t=new Thread(()->{
            while(!isQuit){
                System.out.println("线程工作中");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("线程工作完毕");
        });

        t.start();
        Thread.sleep(5000);
        //isQuit=true;
        System.out.println("设置 isDuit 为true");
    }
}





























